package des.wangku.operate.standard.dialog;

import java.net.URL;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import des.wangku.operate.standard.desktop.DesktopConst;
import des.wangku.operate.standard.task.AbstractTask;
import des.wangku.operate.standard.utls.UtilsJar;

/**
 * 弹出窗口
 * 
 * @author Sunjian
 * @version 1.0
 * @since jdk1.8
 */
public class DialogShow {

	private static final int ACC_Vers_Style = SWT.CLOSE | SWT.MIN | SWT.DIALOG_TRIM;

	/**
	 * 查看版本信息
	 * @param at AbstractTask
	 */
	public static final void showTaskVersion(AbstractTask at) {
		if(at==null)return;
		showVersion(at.getBasicClass(),DesktopConst.TaskJarVersionFile);
	}
	/**
	 * 查看版本信息
	 * @param clazz Class&lt;?&gt;
	 * @param filename String
	 */
	public static final void showVersion(Class<?> clazz, String filename) {
		if(clazz==null)return;
		Display display = Display.getDefault();
		Shell shell = new Shell(display, ACC_Vers_Style);
		/* String path = basicClass.getProtectionDomain().getCodeSource().getLocation().getPath(); */
		URL url = UtilsJar.getJarSourceURL(clazz, filename);/* "/update.info" */
		HelpDialog ver = new HelpDialog(shell, 0, url);
		ver.open();
	}
	public static final void showTextContent() {
		Display display = Display.getDefault();
		Shell shell = new Shell(display, ACC_Vers_Style);
		/* String path = basicClass.getProtectionDomain().getCodeSource().getLocation().getPath(); */
		TextCotentDialog ver = new TextCotentDialog(shell, 0);
		ver.open();
	}

}
